const MongoClient = require('mongodb').MongoClient;
const url = "mongodb://taosha_user:apyl8XWP6LSW4JHs@101.35.6.34:27722/taosha";

async function main() {
  const client = await MongoClient.connect(url, {useNewUrlParser: true, useUnifiedTopology: true});
  const db = client.db('taosha');


  let topics = await db.collection('topics')
    .find(
      {sub_tab: '杂谈'}
    ).skip(60000).limit(10000)
    .toArray();


  for (let i = 0; i < topics.length; i++) {
    let topic = topics[i];
    console.log(topic.title);

    if (topic.title.includes('👨‍🎓')) {
      continue;
    }

    let result = await db.collection('topics').updateOne({_id: topic._id}, {
      $set: {
        title: topic.title + ' 👨‍🎓'
      }
    });
    console.log(result.result, i, topics.length);

  }

  client.close();

}

main();
